// IMPORTANT: Read the license included with this code archive.

namespace Hosting
{
    using System.Collections;
    using System.ComponentModel.Design;

    internal class MenuCommandService : IMenuCommandService
    {
        private readonly ArrayList menuCommands;

        public MenuCommandService()
        {
            this.menuCommands = new ArrayList();
        }

        public void AddCommand(System.ComponentModel.Design.MenuCommand command)
        {
            this.menuCommands.Add(command);
        }

        public void AddVerb(System.ComponentModel.Design.DesignerVerb verb)
        {
            // No implementation
        }

        public System.ComponentModel.Design.MenuCommand FindCommand(System.ComponentModel.Design.CommandID commandID)
        {
            return null;
        }

        public bool GlobalInvoke(System.ComponentModel.Design.CommandID commandID)
        {
            foreach (MenuCommand command in this.menuCommands)
            {
                if (command.CommandID == commandID)
                {
                    command.Invoke();
                    break;
                }
            }

            return false;
        }

        public void RemoveCommand(System.ComponentModel.Design.MenuCommand command)
        {
            this.menuCommands.Remove(command);
        }

        public void RemoveVerb(System.ComponentModel.Design.DesignerVerb verb)
        {
            // No implementation
        }

        public void ShowContextMenu(System.ComponentModel.Design.CommandID menuID, int x, int y)
        {
        }

        public System.ComponentModel.Design.DesignerVerbCollection Verbs
        {
            get
            {
                return new DesignerVerbCollection();
            }
        }
    }
}